package com.itheima.web;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.entity.Result;
import com.itheima.pojo.Setmeal;
import com.itheima.service.SetmealService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author: libin
 * @date: 2019/11/26 10:27
 * @version: 1.0
 * @describe:
 */
@RequestMapping("/setmeal")
@RestController
public class SetmealController2 {
    @Reference
    private SetmealService setmealService;

    /**
     * 查询所有套餐
     * @return
     */
    @RequestMapping("getSetmeal")
    public Result getSetmeal() {
       List<Setmeal> setmeals = setmealService.getSetmeal();
       return new Result(true,"",setmeals);
    }

    /**
     * 根据id查询套餐详情
     * @return
     */
    @RequestMapping("findById")
    public Result findById(int id) {
       Setmeal setmeal = setmealService.findByIdBatch(id);
        return new Result(true,"",setmeal);
    }

    /**
     * 订阅中的套餐基本信息
     * @param id
     * @return
     */
    @RequestMapping("findBySetmealId")
    public Result findBySetmealId(int id) {
        Setmeal setmeal = setmealService.findBySetmealId(id);
        return new Result(true,"",setmeal);
    }


}
